$(function(){
	KontorXGMap.init();
	
    // zwijanie obszaru katalogu
    var district = $('#district');
    var activeDistrict = district.find('.selected');
    if (activeDistrict.hasClass('.selected') && activeDistrict.parents('ul').size() > 1) {
        var siblingsActiveDistrict = activeDistrict.parent('li').siblings();
		
        var textShow = 'Pokaż wszystkie dzielnice &darr;';
        var textHide = 'Ukryj wszystkie dzielnice &uarr;';
		
        var showAllAction = $('<span/>')
        .html(textHide)
        .addClass('toggle')
        .toggle(
        function() {
            $(this).html(textShow);
            siblingsActiveDistrict.hide();
            return false;
        },
        function() {
            $(this).html(textHide);
            siblingsActiveDistrict.show();
            return false;
        }
    );
		
        showAllAction.click();
	
        var showAll = $('<li/>')
        .addClass('toggle')
        .html(showAllAction);
		
        district.find('ul:eq(0)').append(showAll);
    }
});